package com.show.mytest;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;

public class Test07_Files_Path {
    public static void main(String[] args) throws IOException {
        // 创建Path对象
        Path path = Paths.get("F:/create.txt");
        // 调用Files的静态方法exists
        boolean b = Files.exists(path);
        // 输出
        System.out.println(b);
        // 调用Files的静态方法createFile 根据Path创建文件
        Path file = Files.createFile(path);
        // 根据Path创建文件夹对象
        Path directory = Files.createDirectory(Paths.get("F:/aa"));// 单层文件夹
        Path directories = Files.createDirectories(Paths.get("F:/a/aa")); // 多层文件夹
        // 文件复制
        Files.copy(Paths.get("F:/配置.txt"),Paths.get("F:/配置3.txt"), StandardCopyOption.REPLACE_EXISTING);


        // 逐行读取文件
        BufferedReader br = Files.newBufferedReader(Paths.get("F:/配置.txt"), Charset.forName("utf8"));
        System.out.println(br.readLine());
        br.close();
    }
}
